# -*- coding: utf-8 -*-
# @Author : HaleShi
# @Time : 2023-07-03
# @File : 13_v.8.6.3_complete.py

import requests

from urllib.parse import quote_plus


def gen_Query():
    Query_String = {
        "device": "3e56104c8b41fc4db7a72972e298fa711bf0135e",  # 3e56104c8b41fc4db7a72972e298fa711bf0135e
        "ver": "640",
        "screen_width": "1440",
        "screen_height": "2712",
        "model": "Pixel+2+XL",
        "sdkver": "29",
        "platform": "android",
        "releasever": "10",
        "channel": "Nearme",
        "latt": "0",
        "lngt": "0",
        "networkType": "0",
        "token": "",
        "userStatus": "0 HTTP/1.1"
    }

    datalist = []
    for k, v in Query_String.items():
        ele = f"{k}={v}"
        datalist.append(ele)
    result = "&".join(datalist)
    return result


def gen_data():
    password = "Pneqv/aCWUxlagDjPcT1oQ=="
    password = quote_plus(password)
    mac = quote_plus("96:C2:9F:2E:3E:FF")

    data = {
        "username": 17602167906,
        "password": "Pneqv/aCWUxlagDjPcT1oQ==",
        "sign": "4492de586ed0392156d77a421b1ab866",
        "androidid": "9b030266fede4c4a",
        "mac": mac,
        "imei": "",
        "density": "3.5",
        "brand": "google"
    }
    datalist = []
    for k, v in data.items():
        ele = f"{k}={v}"
        datalist.append(ele)
    result = "&".join(datalist)
    return result


def run():
    Query_String = gen_Query()
    print(Query_String)
    data = gen_data()
    print(data)
    res = requests.post(
        url="https://uicapi.yoloho.com/user/login?{}".format(Query_String),
        data=data,
        headers={
            "User-Agent": "Mozilla/5.0 (Linux; Android 10; Pixel 2 XL Build/QQ3A.200805.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/114.0.5735.196 Mobile Safari/537.36",
            "Host": "uicapi.yoloho.com",
            "Connection": "Keep - Alive",
            "Content - Length": "161",
            "Content - Type": "application / x - www - form - urlencoded"
        }
    )
    print(res.text)


run()
